﻿using System;
using Ping.Core;

namespace Ping.Server.Jobs
{
	/// <summary>
	/// Represents an abstract job that returns a result when it is finished.
	/// </summary>
	public abstract class Job
	{
		/// <summary>
		/// The type of the request that is expected to be given to this job.
		/// </summary>
		public abstract Type RequestType { get; }

		/// <summary>
		/// The type of the result that is expected to be returned from this job.
		/// </summary>
		public abstract Type ResultType { get; }

		public abstract string Name { get; }

		/// <summary>
		/// Performs the given job.
		/// </summary>
		/// <remarks>
		/// Any implementation must be safe to be called from multiple threads on the same instance.
		/// Any implementation must throw an exception in case the job cannot be performed (or some error occured while performing it).
		/// </remarks>
		/// <param name="request">The request for the job</param>
		/// <returns>The result in case the job finished successfully</returns>
		public abstract Result Perform(Request request);
	}
}